home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Communications / General / LineShare Folder / Put Onto Productions Disks / LineShare Scripts / Rockwell Fax1&ARA < prev    next >
Text File  |  1994-02-10  |  6KB  |  311 lines

  1. ! Version 2.1
  2. !
  3. !$ Use this script with Rockwell-based (Supra, Xeba, Zoom, etc) 14400bps fax modems.
  4. !$ Supports: fax and ARA incoming calls.
  5.  
  6. !$ Make sure that *Class 1* fax software is installed, and that your
  7. !$ modem HAS THE NEW ROMs supporting adaptive answering.
  8. !
  9. !$ A cable for hardware handshaking is required
  10.  
  11. ^2 Speaker On:        = Enum("Never" = "0","During Connect" = "1", "Always"="2") "1"
  12. ^3 Speaker Volume:       = Enum("Low"="1","Medium"="2","High"="3") "2"
  13. ^4 Answer On:         = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  14. ^6 Handshake wires:   = Bool("Both"="&D0\K0","CTS only"="&D2\K5") "&D2\K5"
  15. ! ------------------------------------------
  16. ! Resetting the modem:
  17. ! ------------------------------------------
  18. @Hangup
  19.   SetTries 2
  20.   Flush
  21.   HsReset 0,0,17,19,0,0
  22. !
  23. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  24. ! to enter the command mode
  25. !
  26. @Label 1
  27.   matchclr
  28.   matchstr 1 2 "OK\r\n"
  29.   write "ATH0&F\r"
  30.   matchread 20
  31.   ChrDelay 1
  32.   Write "+++"
  33.   ChrDelay 0
  34.   DtrClear
  35.   LBreak
  36.   DtrSet
  37. !
  38.   DecTries
  39.   IfTries 0 1
  40. !
  41. ! OSErr -6019 "Modem error - the modem is not responding"
  42. !
  43.   exit -6019
  44. @Label 2
  45.   write "AT+FCLASS=0\r"
  46.   Jsr 100
  47.   write "AT+FAE=0\r"
  48.   Jsr 100
  49.   exit 0
  50.  
  51. ! ------------------------------------------
  52. !    Receiving incoming calls
  53. ! ------------------------------------------
  54. @ANSWER
  55. !
  56. ! Set the modem preferred speed first
  57. !
  58.   SerReset 19200,0,8,1
  59.   Jsr 80
  60.  
  61. @Label 10
  62. !
  63. ! Set the common options
  64.   Jsr 70
  65. !
  66. ! Set the communication options:
  67. ! • \N0 &Q6: Normal connection (for ARA)
  68. ! • &K3: HW flow control       (for ARA, Fax should not use a handshake on receiving)
  69. ! • W1:  report connection speed
  70. !
  71.   Write "AT\\N0&Q6&K3W1\r"
  72.   Jsr 100
  73. !
  74. ! Set Fax mode
  75. !
  76.   Write "AT+FCLASS=1\r"
  77.   Jsr 100
  78.   Write "AT+FAE=1\r"
  79.   Jsr 100
  80. !
  81. ! It's for Rockwell ONLY! Set FCLASS to 0 again - otherwise,
  82. ! it cannot accept data calls
  83. !
  84.   Write "AT+FCLASS=0\r"
  85.   Jsr 100
  86. !
  87. ! Tell the modem to determine the type of the incoming call
  88. ! Fetch the tube after ^4 rings
  89. !
  90.   Write "ATS0=^4V0\r"
  91.   Jsr 110
  92. !
  93. ! Everything is ready - let's sit and wait for a call
  94. ! We'll wait for 2 minutes, then reinitiate the modem
  95. !
  96.   Note "Waiting for a fax or ARA call…"
  97.   MatchClr
  98.   matchstr 02 40 "47\r"
  99.   MatchStr 03 41 "48\r"
  100.   MatchStr 04 42 "49\r"
  101.   MatchStr 05 43 "50\r"
  102.   MatchStr 06 44 "51\r"
  103.   MatchStr 07 45 "52\r"
  104.   MatchStr 09 31 "33\r"
  105.   matchstr 10 18 "2\r"
  106.   matchstr 12 30 "1\r"
  107.   matchstr 13 17 "3\r"
  108.   matchstr 14 17 "8\r"
  109.   matchstr 15 17 "7\r"
  110. @Label 16
  111.   Matchread 1200
  112. @Label 17
  113.   Note "Tuning again…"
  114.   Write "ATV1\r"
  115.   Jsr 100
  116.   Jump 10
  117. @Label 18
  118.   Note "Ring…"
  119.   jump 16
  120. !
  121. ! Data connection has been established (we read "CARRIER")
  122. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  123. ! if it was an incoming call, put the "RING" before the "CONNECT"
  124. !
  125. @Label 20
  126.   QueueInput "\r\nCARRIER "
  127.   ifOriginate 21
  128.   QueueInput "\r\nRING\r\n"
  129. @Label 21
  130.   Attach "ARA" (DTR,Escape,TimeLimit=0)
  131. !
  132. ! Fax connection has been established (we read "FAX")
  133. ! Put the +FCON back to the buffer,
  134. ! if it was an incoming call, put the "RING" before the "+FCON"
  135. ! Attach the "Fax" subPort
  136. !
  137. @Label 30
  138.   QueueInput "1\r"
  139.   ifOriginate 32
  140. @Label 31
  141.   QueueInput "2\r2\r"
  142. @Label 32
  143.   Attach "Fax" (Reset(2400),IdleLimit=30)
  144.  
  145. !
  146. ! Converting numeric responses into the verbal
  147. !
  148. @Label 40
  149.   QueueInput "2400\r\n"
  150.   Jump 20
  151. @Label 41
  152.   QueueInput "4800\r\n"
  153.   Jump 20
  154. @Label 42
  155.   QueueInput "7200\r\n"
  156.   Jump 20
  157. @Label 43
  158.   QueueInput "9600\r\n"
  159.   Jump 20
  160. @Label 44
  161.   QueueInput "12000\r\n"
  162.   Jump 20
  163. @Label 45
  164.   QueueInput "14400\r\n"
  165.   Jump 20
  166.  
  167. ! ------------------------------------------
  168. ! Originating a call through the "ARA" subport
  169. ! ------------------------------------------
  170. @ORIGINATE "ARA"
  171.   SerReset 19200,0,8,1
  172.   Jsr 80
  173. !
  174. ! Set the common options
  175. !
  176.   Jsr 70
  177. !
  178. ! Set the Data mode:
  179. ! • \N0 &Q6:Normal connection (no compression, correction - for ARA)
  180. ! • &K3: HW Handshake
  181. ! • S7:  time-out (90 sec) for long-distance call (if you use them)
  182. ! • W1:  report connection rate
  183. !
  184.   Write "AT\\N0&Q6&K3S7=90W1\r"
  185.   Jsr 100
  186. !
  187. ! Prepare to receive all error result codes, dial the number
  188. !
  189.   Jsr 90
  190.   MatchStr 1 20 "\r\nCARRIER "
  191.   MatchRead 1000
  192.   Write "\r"
  193.   Exit -6019
  194.  
  195. ! ------------------------------------------
  196. ! Originating a call through the "Fax" subPort
  197. ! ------------------------------------------
  198. @ORIGINATE "Fax" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
  199. !
  200. ! Set the "Fax" speed
  201. !
  202.   SerReset 19200,0,8,1
  203.   Jsr 80
  204. !
  205. ! Set the common options
  206. !
  207.   Jsr 70
  208. !
  209. ! Set the Fax mode
  210. ! &K4: Xon/Xoff handshake
  211. ! &S0: DSR always on (see above)
  212. !
  213.   Write "AT&S0&K4+FCLASS=1\r"
  214.   Jsr 100
  215. !
  216. ! Now emit all commands that the application has sent to that port,
  217. ! except "FCLASS", etc
  218. !
  219.   EmitClear "FCLASS","V","X","E"
  220.   Jsr 60
  221.   Write "ATV0\r"
  222.   Jsr 110
  223. !
  224. ! Prepare to receive all error result codes, dial the number
  225. !
  226.   MatchClr
  227.   MatchStr 01 30 "1\r"
  228.   MatchStr 13 93 "3\r"
  229.   MatchStr 14 94 "8\r"
  230.   MatchStr 15 92 "7\r"
  231.   Write "ATD^1\r"
  232.   HsReset *
  233.   MatchRead 900
  234.   Write "\r"
  235.   Exit -6019
  236. !
  237. ! This section emits all modem commands sent from the client application
  238. ! For each set of commands the "OK" answer is awaited
  239. !
  240. @Label 60
  241.   EmitStart
  242. @Label 61
  243.   EmitCommand 62
  244.   Jsr 100
  245.   Jump 61
  246. @Label 62
  247.   return
  248. !
  249. ! This section initiates the modem before ANSWER and ORIGINATEs:
  250. ! extended responses + connect at the highest rate + speaker control +
  251. ! reset on Dtr drop + DCD valid
  252. ! Verbal responses mode, no echo 
  253. !
  254. @Label 70
  255.   Write "ATX4N1M^2L^3^6&C1V1E0\r"
  256.   Jsr 100
  257.   return 
  258.  
  259. !
  260. ! This section syncronize the modem after the serial port speed switching
  261. !
  262. @Label 80
  263.   ChrDelay 1
  264.   Write "AT\r"
  265.   ChrDelay 0
  266.   Jsr 100
  267.   return
  268. !
  269. ! Prepare to receive error result codes, send the dialing command and
  270. ! set the user's handshake mode
  271. !
  272. @Label 90
  273.   MatchClr
  274.   MatchStr 2 91 "NO DIALTONE\r\n"
  275.   MatchStr 3 92 "BUSY\r\n"
  276.   MatchStr 4 93 "NO CARRIER\r\n"
  277.   MatchStr 5 94 "NO ANSWER\r\n"
  278.   Write "ATD^1\r"
  279.   HsReset *
  280.   return
  281. @Label 91
  282.   exit -6020
  283. @Label 92
  284.   exit -6022
  285. @Label 93
  286.   exit -6021
  287. @Label 94
  288.   exit -6023
  289. !
  290. ! Processing the AT command:
  291. ! OK -> proceed
  292. ! ERROR or TimeOut ->exit -6019
  293. ! It can be called AFTER the "Write" command, since LineShare buffers input
  294. !
  295. @Label 100
  296.   MatchClr
  297.   MatchStr 1 103 "\r\nOK\r\n"
  298.   MatchStr 2 102 "\r\nERROR\r\n"
  299. @Label 101
  300.   MatchRead 20
  301. @Label 102
  302.   Exit -6019
  303. @Label 103
  304.   return
  305.  
  306. @Label 110
  307.   MatchClr
  308.   MatchStr 1 103 "0\r"
  309.   MatchStr 2 102 "4\r"
  310.   Jump 101
  311.